var CW = 300;
var CH = 60;
c3.width = CW;
c3.height = CH;
function randomNum(n,m){
  if (n===null)n=0;
  return Math.floor(Math.random()*(m-n+1)+n)
}
function randomColor(n,m){
  return `rgb(${randomNum(n,m)},${randomNum(n,m)},${randomNum(n,m)})`
}
var ctx = c3.getContext("2d");
var str = 'ABCDEFGHJKLMNPQRSTWXY3456789';
var num = randomNum(0,str.length-1);
var txt = getStrs(1).join("");
var arrTxt = [],ramdomTxt = '';

c3.style.background=randomColor(230,240);
ctx.textBaseline = 'top';
for(var i=0;i<5;i++){
  ctx.strokeStyle = randomColor(0,150);//字体颜色
  var fs=randomNum(CH/2,CH);
  ctx.font = `${fs}px SimHei`;//字体大小
  ctx.save();//保存状态
  //添加随机偏移距离
  if(i==0){
    var tempD = randomNum(CW/60,CW/20);
  }else{
    var tempD = randomNum(-CW/20,CW/20);
  }
  ctx.translate((CW/5)*i+CW/10+tempD,(CH/2)+randomNum(-5,5));//移动位置
  ctx.rotate(randomNum(-20,20)*Math.PI/180);//随机角度
  //生成随机文字
  var txt = str[randomNum(0,str.length-1)];
  arrTxt.push(txt);
  ctx.strokeText(txt,-fs/2,-fs/2);//随机文字
  ctx.restore();
}
ramdomTxt = arrTxt.join('');
console.log(ramdomTxt)
//绘制干扰线
for(var k=0;k<5;k++){
  ctx.beginPath();
  ctx.moveTo(randomNum(0,CW),randomNum(0,CH));
  ctx.lineTo(randomNum(0,CW),randomNum(0,CH));
  ctx.strokeStyle = randomColor(0,255);
  ctx.stroke();
}
//绘制圆点
for(var j=0;j<100;j++){
  ctx.beginPath();
  ctx.arc(randomNum(0,CW),randomNum(0,CH),1.5,0,2*Math.PI);
  ctx.fillStyle=randomColor(180,230);
  ctx.fill();
}
